from hw5 import *

U_basis = [Vec({0, 1, 2, 3, 4, 5},{0: 2,  1: 1,   2: 0,  3: 0, 4: 6,   5: 0}),
           Vec({0, 1, 2, 3, 4, 5},{0: 11, 1: 5,   2: 0,  3: 0, 4: 1,   5: 0}),
           Vec({0, 1, 2, 3, 4, 5},{0: 3,  1: 1.5, 2: 0,  3: 0, 4: 7.5, 5: 0})]
V_basis = [Vec({0, 1, 2, 3, 4, 5},{0: 0,  1: 0,   2: 7,  3: 0, 4: 0,   5: 1}),
           Vec({0, 1, 2, 3, 4, 5},{0: 0,  1: 0,   2: 15, 3: 0, 4: 0,   5: 2})]
w = Vec({0, 1, 2, 3, 4, 5},{0: 2, 1: 5, 2: 0, 3: 0, 4: 1, 5: 0})
#dsc(U_basis, V_basis, w) == (Vec({0, 1, 2, 3, 4, 5},{0: 2.0, 1: 4.999999999999972, 2: 0.0, 3: 0.0, 4: 1.0, 5: 0.0}),  Vec({0, 1, 2, 3, 4, 5},{0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0.0}))

combined = U_basis + V_basis
sol = vec2rep(combined,w)

u = sum(sol[i] * U_basis[i] for i in range(len(U_basis)))
v = sum(sol[i+len(U_basis)] * V_basis[i] for i in range(len(V_basis)))

print(u,v)

